﻿using System.ServiceModel;
using Xunit;

namespace Unity.Extensions
{
    public class UnityServiceBehaviorTests
    {
        [Fact]
        public void RepositoryIsInjectedIntoService()
        {
            ServiceHost serviceHost = new ServiceHost(typeof(TestService));
            NetTcpBinding binding = new NetTcpBinding();
            serviceHost.Open();

            ITestService proxy = ChannelFactory<ITestService>.CreateChannel(binding, new EndpointAddress("net.tcp://localhost:8080"));

            Assert.DoesNotThrow(proxy.TestOperation);

            ((ICommunicationObject)proxy).Close();
            serviceHost.Close();
        }
    }
}